/**
 * 
 */
package com.swim.coach.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.swim.coach.entity.Coach;
import com.swim.coach.dao.CoachDao;
import com.jeesite.modules.file.utils.FileUploadUtils;

/**
 * 私教Service
 * @author 刘军武
 * @version 2021-05-06
 */
@Service
@Transactional(readOnly=true)
public class CoachService extends CrudService<CoachDao, Coach> {
	
	/**
	 * 获取单条数据
	 * @param coach
	 * @return
	 */
	@Override
	public Coach get(Coach coach) {
		return super.get(coach);
	}
	
	/**
	 * 查询分页数据
	 * @param page 分页对象
	 * @param coach
	 * @return
	 */
	@Override
	public Page<Coach> findPage(Page<Coach> page, Coach coach) {
		return super.findPage(page, coach);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param coach
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(Coach coach) {
		super.save(coach);
		// 保存救生员证图片
		FileUploadUtils.saveFileUpload(coach.getId(), "lifeguard_image");
		// 保存教练证图片
		FileUploadUtils.saveFileUpload(coach.getId(), "coach_image");
	}
	
	/**
	 * 更新状态
	 * @param coach
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(Coach coach) {
		super.updateStatus(coach);
	}
	
	/**
	 * 删除数据
	 * @param coach
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(Coach coach) {
		super.delete(coach);
	}
	
}